#pragma once
#include "TaskQueue.h"
#include <thread>
#include <vector>
using namespace std;

class ThreadPool
{
public:
    ThreadPool(size_t threadNum, size_t queSize);
    ~ThreadPool();

    void start();
    void stop();

    void addTask(Task *ptask);

private:
    Task *getTask();
    void doTask(); // 线程入口函数

private:
    size_t _threadNum;
    vector<thread> _threads;
    size_t _queSize;
    TaskQueue _taskQue;
    bool _isExit;
};